import random

from celery import shared_task

from apps.system.models import User


@shared_task
def demo(x, y):
    """
     后台添加数据时输入路径为apps.system.tasks.demo.demo
     并在init文件中引入:
    """
    print("start tasks.demo now!")
    print("tasks.demo no.1 end!")
    return x+y

@shared_task
def demo2(x, y):
    """
     后台添加数据时输入路径为apps.system.tasks.demo.demo
     并在init文件中引入:
    """
    print("start demo now!")
    print("demo no.1 end!")
    user = User.objects.filter(username='admin').update(first_name='admin' + str(random.randint(0, 9)))
    return x+y